package com.pinyoumei.app.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.pinyoumei.app.R;
import com.pinyoumei.app.bean.CouponBean;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2021-06-26.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2021-06-26        Administrator             新增Person类
 * 2021-06-26        Administrator             增加sex属性
 */
public class CouponAdapter extends BaseQuickAdapter<CouponBean.ResultBean.CouponListBean, BaseViewHolder> {
    public CouponAdapter(int layoutResId, @Nullable List<CouponBean.ResultBean.CouponListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CouponBean.ResultBean.CouponListBean item) {
        ImageView rl_bg = helper.getView(R.id.rl_bg);
        ImageView iv_out_time = helper.getView(R.id.iv_out_time);
        TextView tv_use = helper.getView(R.id.tv_use);

//        优惠券状态 0待使用 1已使用 2已过期
        switch (item.getCoupon_status()) {
        	case 0:
                tv_use.setText("立即使用");
                rl_bg.setImageResource(R.mipmap.ic_coupon_bg_1);
                iv_out_time.setVisibility(View.GONE);
        		break;

            case 1:
                tv_use.setVisibility(View.GONE);
                rl_bg.setImageResource(R.mipmap.ic_coupon_bg_2);
                iv_out_time.setVisibility(View.VISIBLE);
                iv_out_time.setImageResource(R.mipmap.ic_znk_bg_7);
                break;
            case 2:

                tv_use.setVisibility(View.GONE);
                rl_bg.setImageResource(R.mipmap.ic_coupon_bg_2);
                iv_out_time.setVisibility(View.VISIBLE);
                iv_out_time.setImageResource(R.mipmap.ic_znk_bg_6);
                break;
        	default:
        		break;
        }
        
        helper.setText(R.id.tv_coupon_amount,"¥" + item.getCoupon_amount());

        helper.setText(R.id.tv_coupon_title, item.getCoupon_title()+"");

        helper.setText(R.id.tv_use_condition, "适用于：" + item.getUse_condition()+"");

        helper.setText(R.id.tv_expire_time, "有效期：" + item.getExpire_time()+"");




    }
}
